package com.hujinwen.esay.t115;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by joe on 2020/5/12
 * FIXME 本机计算结果和网站上的计算结果不同
 */
public class Test1 {


    public static void main(String[] args) {
        final MinStack stack = new MinStack();
        stack.push(-1);
        final int top = stack.top();
        final int min1 = stack.getMin();
        System.out.println();
    }

}

class MinStack {

    private static final List<Integer> stack = new LinkedList<>();

    /**
     * initialize your data structure here.
     */
    public MinStack() {

    }

    public void push(int x) {
        stack.add(x);
    }

    public void pop() {
        if (stack.isEmpty()) {
            return;
        }
        stack.remove(stack.size() - 1);
    }

    public int top() {
        if (stack.isEmpty()) {
            return 0;
        }
        return stack.get(stack.size() - 1);
    }

    public int getMin() {
        return Collections.min(stack);
    }
}
